<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
    #t,
    #tt {
      /* border: #ccc thin solid; */
      width: 250px;
      height: 60px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 20px;
      background-color: pink;
    }

    .t-num {
      height: 100%;
      overflow: hidden;
      /*background-color: #ccc;*/
      width: 46px;
      line-height: 60px;
      text-align: center;
    }

    .t-num-s {
      display: block;
      height: 100%;
      width: 100%;

      font-size: 72px;
      font-weight: bold;
      color: #fff;
      /*border: red thin solid;*/
    }

    .top {
      height: 2000px;
      background-color: green;
    }

    body {
      height: 5000px;
    }
  </style>
</head>

<body>
  <div class="top">

  </div>
  <div id="t">

  </div>
  <!-- <div id="tt">

  </div> -->
</body>

<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="./digitalScroll.js"></script>
<!-- <script src="./index.js"></script> -->
<script>
  $(function () {

    let seeH = $(window).height() // 窗口的可视区域高度
    console.log(seeH);
    let itemH = $('#t').offset().top // 元素距离页面顶部的距离
    console.log(itemH);
    let flag = true
    // console.log(flag, '11111111111111111111');


    $(document).scroll(function () {
      let bol = $(window).scrollTop() // 窗口滚动的顶部偏移量
      console.log(bol);
      if (flag) {
        if (bol > itemH - seeH) {
          flag = false
          // console.log(flag, '2222222222222222');
          console.log('显示');
          let num = 920
          //配置项 p:滚动速度，height:数字容器的高度，spanclass：数字容器的classname,divClasss: span容器的class
          // numchange.config({p: 5}).change('t', num)
          let t = numchange()
          t.change('t', num)
          setInterval(() => {
            t.change('t', num)
          }, 3000)

          // let num1 = 12345
          // let t1 = numchange()
          // t1.change('tt', num1)
          // setInterval(() => {
          //   t1.change('tt', num1)
          // }, 3000)
        }
      }
    })
    // console.log(flag, '333333333333333');

  })




</script>

</html>